<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			window.onload=function()
			{
				var btn01=document.getElementById("btn01");
				
				bind(btn01,"click",function()
				{
					alert(1);
				});
				bind(btn01,"click",function()
				{
					alert(2);
				});
				
				
				//！！！！这个函数挺重要的
				function bind(obj,eventStr,callback)
			    {
				if(obj.addEventListener)  //解决兼容性问题
				{
					obj.addEventListener(eventStr,callback,false);
				}
				else
				{
					obj.attachEvent("on"+eventStr,function()
					{
						callback.call(obj);   //可以将window变成button
					})
				}
			}
			}
			
		</script>
	</head>
	<body>
		<button id="btn01">点我一下</button>
	</body>
</html>